//
//  TheredemptionViewController.m
//  TenThousand
//
//  Created by 我的 on 16/7/18.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import "TheredemptionViewController.h"
#import "CapitalSubsidiaryViewController.h"
#import "AgreementView.h"
#import "InvestmentVC.h"

@interface TheredemptionViewController ()

/**投资名 编号*/
@property (weak, nonatomic) IBOutlet UILabel *name;
/**投资金额*/
@property (weak, nonatomic) IBOutlet UILabel *money;
/**期限*/
@property (weak, nonatomic) IBOutlet UILabel *deadline;
/**起息日期*/
@property (weak, nonatomic) IBOutlet UILabel *dateOfValue;
/**违约金比例*/
@property (weak, nonatomic) IBOutlet UILabel *penaltyScale;
/**年利率*/
@property (weak, nonatomic) IBOutlet UILabel *annualRate;
/**预计收益*/
@property (weak, nonatomic) IBOutlet UILabel *expectIncome;
/**当前收益*/
@property (weak, nonatomic) IBOutlet UILabel *currentIncome;
/**申请日期*/
@property (weak, nonatomic) IBOutlet UILabel *applyDate;
/**违约金*/
@property (weak, nonatomic) IBOutlet UILabel *penalty;


@end

@implementation TheredemptionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createLeft:[UIImage imageNamed:@"ZHSZicon_03"] leftClick:^{
        [self.navigationController popViewControllerAnimated:YES];
    } right:nil rightClick:nil];
    self.navigationItem.title = @"赎回中的投资";
    
    
    [self setValue];
}

- (void)setValue{

    
    _name.text          = [NSString stringWithFormat:@"%@:%@", _model.Project, _model.Code];
    _money.text         = [NSString stringWithFormat:@"投资金额:%.2f", [_model.Dedit floatValue]];
    _deadline.text      = [NSString stringWithFormat:@"期限:%@", _model.TeamYear];
        NSArray *arrsta = [_model.AddDate componentsSeparatedByString:@" "];
    _dateOfValue.text   = [NSString stringWithFormat:@"起息日期:%@", arrsta[0]];
    _penaltyScale.text  = [NSString stringWithFormat:@"违约金比例:%.2f%%", [_model.Rateweiyuejin floatValue]];
    _annualRate.text    = [NSString stringWithFormat:@"年利率:%.2f%%", _model.Rate];
    _expectIncome.text  = [NSString stringWithFormat:@"预计收益%.2f", _model.CurrentAmount];
    _currentIncome.text = [NSString stringWithFormat:@"当前收益:%.2f", [_model.ViolateAmount floatValue]];
        NSArray *arr = [_model.AddDate componentsSeparatedByString:@" "];
    _applyDate.text     = [NSString stringWithFormat:@"回款日期:%@",arr[0]];
    _penalty.text = [NSString stringWithFormat:@"违约金:%.2f", [_model.Weiyue doubleValue]];

}


/**取消*/
- (IBAction)cancel:(id)sender {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *LoginId = [defaults objectForKey:@"LoginId"];
    
    
    NSDictionary *para = @{
                             @"BrrowListId" : _model.BrrowListId,
                             @"RedemId"  : _model.RedemId
                             };
    
    NSString *method = @"Redemp.GetDetelRedeemClear";
    
    [NetWorkManager requestWithType:HttpRequestTypePost withMethodName:method withParaments:para withSuccessBlock:^(NSDictionary *object) {
//        NSLog(@"%@", object);
        if ([object[@"Code"] isEqualToString:@"00000"]) {
            [ToastView showInfoWithStatus:object[@"Message"]];
            [self.navigationController popViewControllerAnimated:YES];
        }
    } withFailureBlock:^(NSError *error) {
//        NSLog(@"%@", error);
    } progress:^(float progress) {
        
    }];
}

//投资协议
- (IBAction)touzi:(id)sender {
    
    CapitalSubsidiaryViewController *capitalView = [[CapitalSubsidiaryViewController alloc] init];
    capitalView.Borrowid = self.model.Borrowid;
    capitalView.BorrowListId = self.model.BorrowListid;
    capitalView.num = 1;
    capitalView.Code = self.model.Code;
    capitalView.ProjectName = self.model.Project;
    [capitalView setSelectIndex: 2];
    [self.navigationController pushViewController:capitalView animated:YES];
}

//投资记录
- (IBAction)touzijilu:(id)sender {
    CapitalSubsidiaryViewController *capitalView = [[CapitalSubsidiaryViewController alloc] init];
    capitalView.Borrowid = self.model.Borrowid;
    capitalView.BorrowListId = self.model.BorrowListid;
    capitalView.num = 1;
    capitalView.Code = self.model.Code;
    capitalView.ProjectName = self.model.Project;
    [capitalView setSelectIndex: 1];
    [self.navigationController pushViewController:capitalView animated:YES];

}

//项目详情
- (IBAction)xiangmu:(id)sender {
    
    CapitalSubsidiaryViewController *capitalView = [[CapitalSubsidiaryViewController alloc] init];
    capitalView.Borrowid = self.model.Borrowid;
    capitalView.BorrowListId = self.model.BorrowListid;
    capitalView.num = 1;
    capitalView.Code = self.model.Code;
    capitalView.ProjectName = self.model.Project;
    [capitalView setSelectIndex: 0];
    [self.navigationController pushViewController:capitalView animated:YES];
}
@end
